home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / system / happyenv / mountenv.asm < prev    next >
Assembly Source File  |  1996-06-18  |  3KB  |  139 lines

  1. *****************************************
  2. *        MountENV        *
  3. *    Mount tool for HappyENV-Handler    *
  4. *    Last change: 18.6.96        *
  5. *****************************************
  6.  
  7. ;See documentation about Copyright&Disclaimer
  8.  
  9. ;Can be started from WB and CLI
  10. ;Tabsize=8
  11.  
  12. ;exec
  13. _LVOOpenLibrary        = -552
  14. _LVOOldOpenLibrary    = -408
  15. _LVOCloseLibrary    = -414
  16. _LVOFindTask        = -294
  17. _LVOWaitPort        = -384
  18. _LVOGetMsg        = -372
  19. _LVOReplyMsg        = -378
  20. _LVOForbid        = -132
  21. _LVOAllocMem        = -198
  22.  
  23. ;expansion
  24. _LVOMakeDosNode        = -144
  25. _LVOAddDosNode        = -150
  26.  
  27. pr_CLI        = 172
  28. pr_MsgPort    = 92
  29. pr_CurrentDir    = 152
  30. sm_NumArgs    = 28
  31. sm_ArgList    = 36
  32.  
  33. dn_Next        = 0
  34. dn_Type        = 4
  35. dn_Task        = 8
  36. dn_Lock        = 12
  37. dn_Handler    = 16
  38. dn_StackSize    = 20
  39. dn_Priority    = 24
  40. dn_Startup    = 28
  41. dn_SegList    = 32
  42. dn_GlobalVec    = 36
  43. dn_Name        = 40
  44. dn_SIZEOF    = 44
  45.  
  46.  
  47. ;init place for needed structures on stack
  48. start    moveq    #20,d5        ;set return-code to FAIL
  49.     move.l    4.w,a6        ;exec-base to a6
  50.     sub.l    a1,a1
  51.     jsr    _LVOFindTask(a6)    ;find this task
  52.     move.l    d0,a4        ;a4=this task
  53.  
  54. ;check for WB or CLI start
  55.     moveq    #0,d6        ;reset WB-msg
  56.     tst.l    pr_CLI(a4)    ;a4=this task
  57.     bne.s    .CLI
  58.     lea    pr_MsgPort(a4),a0    ;it was WB-start
  59.     jsr    _LVOWaitPort(a6)
  60.     lea    pr_MsgPort(a4),a0
  61.     jsr    _LVOGetMsg(a6)
  62.     move.l    d0,d6        ;d6=message from WB
  63.  
  64. .CLI    moveq    #dn_SIZEOF,d0    ;get mem for device node
  65.     move.l    #1<<16!1,d1
  66.     jsr    _LVOAllocMem(a6)
  67.     tst.l    d0
  68.     beq.s    Ende2
  69.     move.l    d0,a2
  70.  
  71.     moveq    #handend-handler,d0    ;init device node
  72.     lea    handler(pc),a1
  73.     bsr    CopyBSTR
  74.     beq.s    Ende2
  75.     move.l    d0,dn_Handler(a2)
  76.     move.l    #2000,dn_StackSize(a2)
  77.     moveq    #5,d0
  78.     move.l    d0,dn_Priority(a2)
  79.     moveq    #-1,d0
  80.     move.l    d0,dn_GlobalVec(a2)
  81.     moveq    #envend-envname,d0
  82.     lea    envname(pc),a1
  83.     bsr    CopyBSTR
  84.     beq.s    Ende2
  85.     move.l    d0,dn_Name(a2)
  86.  
  87.     lea    expname(pc),a1    ;open expansion.library
  88.     move.l    4.w,a6
  89.     jsr    _LVOOldOpenLibrary(a6)
  90.     tst.l    d0
  91.     beq.s    Ende2
  92.     move.l    d0,a6
  93.     move.l    a2,a0        ;add new device node
  94.     moveq    #0,d0
  95.     moveq    #0,d1
  96.     jsr    _LVOAddDosNode(a6)
  97.     tst.l    d0
  98.     beq.s    Ende3
  99.     moveq    #0,d5        ;set return code to OK
  100.  
  101. ;clean up all things used
  102. Ende3    move.l    a6,a1
  103.     move.l    4.w,a6
  104.     jsr    _LVOCloseLibrary(a6)
  105.  
  106. ;end program
  107. Ende2    move.l    d5,d0        ;set return-code
  108.     tst.l    d6        ;wb-msg ? -> started from WB
  109.     bne.s    .Jump
  110.     rts            ;THE END ! from CLI
  111. .Jump    jsr    _LVOForbid(a6)    ;must be in forbid-state
  112.     move.l    d6,a1
  113.     jmp    _LVOReplyMsg(a6)    ;THE END ! from WB
  114.  
  115.  
  116. CopyBSTR    ;entry: d0=size, a1=string
  117.         ;exit:  d0=BSTR
  118.     movem.l    a0-a2/a6,-(sp)
  119.     move.l    a1,a2
  120.     moveq    #1,d1
  121.     move.l    4.w,a6
  122.     jsr    _LVOAllocMem(a6)
  123.     move.l    d0,a1
  124.     lsr.l    #2,d0
  125.     beq.s    .end
  126. .loop    move.b    (a2)+,(a1)+
  127.     bne.s    .loop
  128.     tst.l    d0
  129. .end    movem.l    (sp)+,a0-a2/a6
  130.     rts
  131.  
  132. expname    dc.b    "expansion.library",0
  133. handler    dc.b    18,"L:HappyENV-Handler",0
  134. handend
  135. envname    dc.b    3,"ENV",0
  136. envend
  137.         end
  138.  
  139.